VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Accesso"
   ClientHeight    =   1575
   ClientLeft      =   2835
   ClientTop       =   3360
   ClientWidth     =   3090
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   930.562
   ScaleMode       =   0  'User
   ScaleWidth      =   2901.343
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtUserName 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   345
      Left            =   600
      TabIndex        =   0
      ToolTipText     =   "Inserisci il codice utente"
      Top             =   135
      Width           =   2325
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   390
      Left            =   120
      TabIndex        =   2
      Top             =   1080
      Width           =   1140
   End
   Begin VB.CommandButton cmdEsci 
      Cancel          =   -1  'True
      Caption         =   "&Esci"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   390
      Left            =   1800
      TabIndex        =   3
      Top             =   1080
      Width           =   1140
   End
   Begin VB.TextBox txtPassword 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   345
      IMEMode         =   3  'DISABLE
      Left            =   600
      PasswordChar    =   "*"
      TabIndex        =   1
      ToolTipText     =   "Inserisci la password"
      Top             =   600
      Width           =   2325
   End
   Begin VB.Image Image2 
      Height          =   330
      Left            =   120
      Picture         =   "frmLogin.frx":0000
      Top             =   600
      Width           =   360
   End
   Begin VB.Image Image1 
      Height          =   330
      Left            =   120
      Picture         =   "frmLogin.frx":018A
      Top             =   120
      Width           =   360
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ENTRA As Boolean

Private Sub Form_Load()
    ENTRA = False
    Call TakeCloseOff(Me.hWnd)
End Sub

Private Sub cmdEsci_Click()
    Dim ret As Double
    '/ release object
    Call objMenuEx.Uninstall(frmMain.hWnd, frmMain.ImageList1, MenuEvents)
    Set MenuEvents = Nothing
    Set objMenuEx = Nothing
    ' chiude le connessioni
    Set cnCentro = Nothing
    Set cnPrinc = Nothing
    ' smonta il volume
    ret = Shell(structApri.pathTrueCrypt & "\TrueCrypt.exe /d X /q /s /f", vbHide)
    End
End Sub

Private Sub cmdOK_Click()
    Dim rsLogin As Recordset
    Dim strSql As String
    txtPassword = txtPassword & ""
    txtUserName = txtUserName & ""
    ' cerca l'utente
    If ENTRA Then
        strSql = "SELECT * FROM LOGIN WHERE CHIAVE='" & Apostrophe(txtUserName) & "' AND TIPO=4"
    Else
        strSql = "SELECT * FROM LOGIN WHERE CHIAVE='" & Apostrophe(txtUserName) & "' AND PASSWORD='" & Apostrophe(txtPassword) & "' AND TIPO=4"
    End If
    Set rsLogin = New Recordset
    rsLogin.Open strSql, cnCentro, adOpenForwardOnly, adLockReadOnly, adCmdText
    If rsLogin.EOF And rsLogin.BOF Then
        ' l'utente nn esiste o ha sbagliato ad inserire i dati
        MsgBox "Chiave utente o password sbagliate", vbExclamation, "Accesso"
        txtUserName.SetFocus
        Exit Sub
    Else
        Unload Me
    End If
    Set rsLogin = Nothing
End Sub

Private Sub txtPassword_GotFocus()
    txtPassword.SelStart = 0
    txtPassword.SelLength = Len(txtPassword)
End Sub

Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer)
    ' evita di chiudere il form con alt f4
    If (Shift And vbAltMask) And KeyCode = vbKeyF4 Then
        KeyCode = 0
    End If
End Sub

Private Sub txtUserName_GotFocus()
    txtUserName.SelStart = 0
    txtUserName.SelLength = Len(txtUserName)
End Sub

Private Sub txtUserName_KeyDown(KeyCode As Integer, Shift As Integer)
    ' TEMPORANEO
    If (Shift And vbAltMask) And KeyCode = vbKeyF2 Then
        txtUserName = "admin"
        ENTRA = True
        cmdOK_Click
    End If
    ' evita di chiudere il form con alt f4
    If (Shift And vbAltMask) And KeyCode = vbKeyF4 Then
        KeyCode = 0
    End If
End Sub

